﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Web612.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UploadController : ControllerBase
    {

         public UploadController(IWebHostEnvironment web)
        {
            Web = web;
        }

        public IWebHostEnvironment Web { get; }

        [HttpPost]
         public IActionResult Upol(IFormFile file)
        {
            var nreww=Guid.NewGuid().ToString();
            string path = Web.WebRootPath + @"\pic\" + nreww + file.FileName;
            using (FileStream fs=System.IO.File.Create(path))
            { 
                file.CopyTo(fs);
                 fs.Close();    


            }

            return Ok(@"/pic/" + nreww + file.FileName);



        }
    }
}
